home *** CD-ROM | disk | FTP | other *** search
- /* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Scott MacGregor <mscott@netscape.com>
- * Jens Bannmann <jens.b@web.de>
- * Pete Burgers <updatescanner@gmail.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
- if (typeof(USc_alert_exists) != 'boolean') {
- var USc_alert_exists = true;
- var USc_alert = {
- _animateAlert:function () {
- var prefService = Components.classes['@mozilla.org/preferences-service;1'].getService();
- prefService = prefService.QueryInterface(Components.interfaces.nsIPrefService);
- var prefBranch = prefService.getBranch("extensions.googleredesigned.notifications.");
- var me = USc_alert;
- if (window.outerHeight < me.gFinalHeight) {
- window.screenY -= me.gSlideIncrement;
- window.outerHeight += me.gSlideIncrement;
- setTimeout(me._animateAlert, me.gSlideTime);
- } else {
- if (prefBranch.getBoolPref("playSound")) {
- me._playSound();
- }
- if (!me.gPermanent) {
- setTimeout(me._closeAlert, me.gOpenTime);
- }
- }
- },
- _closeAlert:function () {
- var me = USc_alert;
- if (window.outerHeight > 1) {
- window.screenY += me.gSlideIncrement;
- window.outerHeight -= me.gSlideIncrement;
- setTimeout(me._closeAlert, me.gSlideTime);
- } else {
- if (me.gAlertListener) {
- me.gAlertListener.observe(null, "alertfinished", me.gAlertCookie);
- }
- window.close();
- }
- },
- _playSound:function () {
- var prefService = Components.classes['@mozilla.org/preferences-service;1'].getService();
- prefService = prefService.QueryInterface(Components.interfaces.nsIPrefService);
- var prefBranch = prefService.getBranch("extensions.googleredesigned.notifications.");
- var ioService = Components.classes['@mozilla.org/network/io-service;1'].getService(Components.interfaces.nsIIOService);
- var url;
- var player = Components.classes['@mozilla.org/sound;1'].createInstance(Components.interfaces.nsISound);
- try {
- if (prefBranch.getBoolPref("defaultSound")) {
- url = ioService.newURI("chrome://googleredesigned/content/defaultNotification.wav", null, null);
- } else {
- var file = prefBranch.getComplexValue("soundFile", Components.interfaces.nsILocalFile);
- url = ioService.newFileURI(file);
- }
- player.init();
- player.play(url);
- } catch (ex) {
- }
- },
- gAlertCookie:"",
- gAlertListener:null,
- gAlertTextClickable:false,
- gFinalHeight:50,
- gOpenTime:3000,
- gPermanent:false,
- gSlideIncrement:4,
- gSlideTime:20,
- g_MAX_HEIGHT:134,
- onAlertClick:function () {
- var wm = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator);
- var win = wm.getMostRecentWindow("navigator:browser");
- if (win.toggleSidebar) {
- win.toggleSidebar("viewgoogleredesignedSidebar");
- }
- win.focus();
- },
- onAlertClose:function () {
- var me = USc_alert;
- me._closeAlert();
- },
- onAlertLoad:function () {
- var me = USc_alert;
- try {
- var prefService = Components.classes['@mozilla.org/preferences-service;1'].getService();
- prefService = prefService.QueryInterface(Components.interfaces.nsIPrefService);
- var prefBranch = prefService.getBranch("extensions.googleredesigned.notifications.");
- me.gOpenTime = prefBranch.getIntPref("displayTime") * 1000;
- if (window.arguments[3]) {
- me.gOpenTime *= 2;
- }
- me.gPermanent = prefBranch.getBoolPref("permanent");
- } catch (ex) {
- }
- sizeToContent();
- me.gFinalHeight = window.outerHeight;
- if (me.gFinalHeight > me.g_MAX_HEIGHT) {
- me.gFinalHeight = me.g_MAX_HEIGHT;
- }
- window.outerHeight = 1;
- window.moveTo((screen.availLeft + screen.availWidth - window.outerWidth) - 10, screen.availTop + screen.availHeight - window.outerHeight);
- setTimeout(me._animateAlert, me.gSlideTime);
- },
- prefillAlertInfo:function () {
- var stringbundle = document.getElementById("googleredesigned-alert-strings");
- var label = document.getElementById("message");
- var labelvalue = "";
- if (window.arguments[0] == "Updates saved succesfully for: ") {
- labelvalue = stringbundle.getString("updatesSavedSuccessfullyFor");
- }
- if (window.arguments[0] == "Update saved succesfully for: ") {
- labelvalue = stringbundle.getString("updateSavedSuccessfullyFor");
- }
- if (window.arguments[0] == "Could not connect to update server.") {
- labelvalue = stringbundle.getString("couldntConnectToServer");
- }
- if (window.arguments[0] == "All styles are up-to-date") {
- labelvalue = stringbundle.getString("allStylesAreUptodate");
- }
- label.value = labelvalue;
- if (window.arguments[1]) {
- var label1 = document.createElement("label");
- var label1value = "";
- if (window.arguments[1] == "Try again later.") {
- label1value = stringbundle.getString("tryAgainLater");
- } else {
- label1value = window.arguments[1];
- }
- label1.setAttribute("value", label1value);
- label1.setAttribute("style", "margin-bottom:5px");
- document.getElementById("message").parentNode.appendChild(label1);
- }
- if (window.arguments[2]) {
- var label2 = document.createElement("label");
- var label2value = "";
- if (window.arguments[2] == "Update unavailable for:") {
- label2value = stringbundle.getString("updateAbortedFor");
- }
- if (window.arguments[2] == "Updates unavailable for:") {
- label2value = stringbundle.getString("updatesAbortedFor");
- }
- label2.setAttribute("value", label2value);
- document.getElementById("message").parentNode.appendChild(label2);
- }
- if (window.arguments[3]) {
- label3 = document.createElement("label");
- label3value = window.arguments[3];
- label3.setAttribute("value", label3value);
- label3.setAttribute("style", "margin-bottom:5px");
- document.getElementById("message").parentNode.appendChild(label3);
- }
- }
- }
- }
-